<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var obj  = [{name:"cheng",count:30},{name:"li",count:12},{name:"zhang",count:14}];

        function up(arr,value){
            var res = arr.sort((a,b) =>{
                return a[value]-b[value];
            })
            return res;
        }
        console.log(...up(obj,"count"))

        function down(arr,value){
            var res = arr.sort((a,b) =>{
                return b[value]-a[value];
            })
            return res;
        }
        console.log(...down(obj,"count"))
    </script>
</body>
</html>